    
            <section class="row">
                <div class="col-lg-12">
                    <div>
                        <h1><i class="fa fa-dashboard"></i> <?= $template['title'] ?></h1>
                    </div>
                    <div>
                        <?= $this->breadcrumb->output(); ?>
                    </div>
                </div>
            </section>

        <div id="ajax-container">
            <?php if(isset($template['partials']['notifications'])) echo $template['partials']['notifications']; ?>
            <section class="row">
                <div class="col-12">
                    <div class="panel panel-default tab-container">
                        <div class="panel-heading">
                            <h2 class="panel-title"><i class="glyphicon glyphicon-folder-close"></i> Tabs Preview</h2>
                        </div>
                        <div class="panel-body tabs no-padding tabs-left">
                            
                            <div class="guideline guideline-sticky bg-info">
                                <i class="fa fa-info-circle fa-lg"></i> Panel Guideline Goes Here.
                            </div>
                            <ul class="nav nav-tabs">
                                <?php
                                    foreach($roles as $role)
                                    {
                                        $active = $role === end($roles) ? ' class="active"' : '';
                                        echo "<li{$active}><a href='#{$role['id']}' data-toggle='tab'><i class='fa fa-group'></i> <span class='hidden-xs'>{$role['name']}</span></a></li>\n";
                                    }
                                ?>
                            </ul>
                            <div class="tab-content media-body">
                                <?php
                                    foreach($roles as $role) :
                                    $active = $role === end($roles) ? ' active' : '';
                                ?>
                                <div id="<?= $role['id'] ?>" class="tab-pane<?= $active ?>">
                                    
                                    <form action="<?= base_url() ?>permissions/update" method="post">
                                        <input type="hidden" name="group_id" value="<?= $role['id'] ?>" />
                                        <table class="table table-hover table-bordered table-responsive">
                                            <caption><?= $role['name'] ?></caption>
                                            <thead>
                                                <tr>
                                                    <th class="align-center script_show"><input type="checkbox" name="toggle_all" id="toggle_all" class="toggle"></th>
                                                    <th>Module Name</th>
                                                    <?php foreach($permission_set as $permission_title) : ?>
                                                    <th class="align-center"><?= $permission_title ?></th>
                                                    <?php endforeach ; ?>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                    foreach($modules as $module) :
                                                    $module_name            = isset($module['name']) ? strtolower( str_replace(' ', '_', $module['name']) ) : '';
                                                    $module_permissions     = isset($module['permissions']) ? unserialize($module['permissions']) : '';
                                                ?>
                                                <tr>
                                                    <td class="align-center script_show"><input type="checkbox" name="<?= $module_name ?>" id="<?= $module_name ?>" class="toggle toggle-all"></td>
                                                    <td><label for="<?= $module_name ?>"><?= $module['name'] ?></label></td>
                                                    <?php
                                                        foreach($permission_set as $permission)
                                                        {
                                                            $permission                 = changeCase( $permission, 'human_upper' );
                                                            $module_permission          = in_array($permission, $module_permissions) ? $permission : 'N/A';
                                                            $role_id                    = isset( $permissions[$role['id']][$module['id']]['id'] ) ? $permissions[$role['id']][$module['id']]['id'] : '';
                                                            $role_module_permissions    = isset( $permissions[$role['id']][$module['id']]['group_permissions'] ) ? unserialize($permissions[$role['id']][$module['id']]['group_permissions']) : array();
                                                            $checked                    = isset($role_module_permissions[$permission]) && ($role_module_permissions[$permission] == 1) ? ' checked="checked"' : '';

                                                            echo '<td class="align-center">';
                                                            echo $module_permission === 'N/A' ? 'N/A' : "<input type='checkbox' name='permissions[{$role['id']}-{$module['id']}][{$permission}]' class='toggle-all {$module_name}' value='1'{$checked}>";
//                                                            echo $module_permission === 'N/A' ? 'N/A' : "<input type=\"checkbox\" name=\"{$role_id}[{$permission}]\" class=\"toggle-all {$module_name}\" value=\"1\"{$checked}>";
                                                            echo '</td>';
                                                        }
                                                    ?>
                                                <?php endforeach; ?>
                                            </tbody>
                                        </table>
                                        
                                        <div class="table-pagination">
                                            <button type="submit" class="btn btn-primary">Save</button>
                                            <button type="button" class="btn">Reset</button>
                                        </div>
                                    </form>
                                    
                                </div>
                                <?php endforeach; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
            <!-- page-script -->
            <script src="<?= base_url() ?>js/modules/modules.js"></script>
        </div>